package com.ruoyi.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BaseStore;
import com.ruoyi.base.service.IBaseStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库操作Controller
 * 
 * @author ruoyi
 * @date 2024-01-03
 */
@RestController
@RequestMapping("/base/store")
public class BaseStoreController extends BaseController
{
    @Autowired
    private IBaseStoreService baseStoreService;

    /**
     * 查询仓库操作列表
     */
    @PreAuthorize("@ss.hasPermi('base:store:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseStore baseStore)
    {
        startPage();
        List<BaseStore> list = baseStoreService.selectBaseStoreList(baseStore);
        return getDataTable(list);
    }

    /**
     * 导出仓库操作列表
     */
    @PreAuthorize("@ss.hasPermi('base:store:export')")
    @Log(title = "仓库操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseStore baseStore)
    {
        List<BaseStore> list = baseStoreService.selectBaseStoreList(baseStore);
        ExcelUtil<BaseStore> util = new ExcelUtil<BaseStore>(BaseStore.class);
        util.exportExcel(response, list, "仓库操作数据");
    }

    /**
     * 获取仓库操作详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:store:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(baseStoreService.selectBaseStoreById(id));
    }

    /**
     * 新增仓库操作
     */
    @PreAuthorize("@ss.hasPermi('base:store:add')")
    @Log(title = "仓库操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseStore baseStore)
    {
        return toAjax(baseStoreService.insertBaseStore(baseStore));
    }

    /**
     * 修改仓库操作
     */
    @PreAuthorize("@ss.hasPermi('base:store:edit')")
    @Log(title = "仓库操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseStore baseStore)
    {
        return toAjax(baseStoreService.updateBaseStore(baseStore));
    }

    /**
     * 删除仓库操作
     */
    @PreAuthorize("@ss.hasPermi('base:store:remove')")
    @Log(title = "仓库操作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseStoreService.deleteBaseStoreByIds(ids));
    }
}
